package com.hwua.view;

import com.hwua.service.UserService;
import com.hwua.serviceimpl.UserServiceImpl;
import com.hwua.util.InputTools;

/**
 * 修改用户VIP等级界面
 * @author admin
 */
public class AlterUserLevelView extends AbstractView{
    private int id;
    public AlterUserLevelView(int id){
        this.id = id;
    }
    @Override
    public AbstractView showView() {
        System.out.println("---------------------------------------------------------------");
        System.out.println("*注意*：每个VIP等级可以享受不同折扣的租车优惠，请慎重修改！");
        System.out.println("VIP等级\t\t\t折扣力度");
        System.out.println("\t1\t\t\t无折扣");
        System.out.println("\t2\t\t\t9.5折");
        System.out.println("\t3\t\t\t9折");
        System.out.println("\t4\t\t\t8.5折");
        System.out.println("\t5\t\t\t8折");
        System.out.println("请输入用户VIP等级（1-5）:");
        int level = InputTools.checkIntInput(1,5);
        UserService us = new UserServiceImpl();
        boolean result = us.alterUserLevel(id,level);
        if(result){
            System.out.println("修改等级成功！");
            nextView=new AdminInformationView();
        }else{
            System.out.println("修改失败，请重新修改！");
            nextView = new AlterUserLevelView(id);
        }
        return nextView;
    }
}
